import {
  DIC
} from '@/const/dic'
export const option = {
  index:true,
  indexLabel:'序号',
  border: true,
  selection: false,
  menuBtn: true,
  addBtn:false,
  cellBtn: false,
  editBtn: false,
  delBtn: false,
  dicData: DIC,
  columnBtn: false,
  refreshBtn:false,
  size: 'mini',
  align: "center",
  menuWidth: 280,
  menuAlign: "center",
  column: [{
      label: "审批单号",
      prop: "approvalNumber",
  },{
      label: "审批状态",
      prop: "appointmentStatus",
      slot: true,
  },{
      label: "预约时间",
      prop: "startTime",
      width: 120,
      slot: true
  },{
      label: "设备类别",
      prop: "equipmentTypeName"
  },{
      label: "设备编码",
      prop: "coded",
  },{
      label: "设备名称",
      prop: "equipmentName",
  },{
      label: "型号",
      prop: "marking",
  },{
      label: "品牌",
      prop: "brand",
  },{
      label: "实验室",
      prop: "laboratoryName",
  },{
      label: "预约部门/人",
      prop: "applyuser",
      slot: true,
  },{
      label: "申请时间",
      prop: "applyForTime",
      width: 150,
  },
  ]
};
export const optionAdd = {
    index:true,
    size: 'mini',
    indexLabel:'序号',
    border: true,
    selection: true,
    menuBtn: true,
    addBtn:false,
    cellBtn: false,
    editBtn: false,
    delBtn: false,
    dicData: DIC,
    align: "center",
    menuWidth: 110,
    menuAlign: "center",
    columnBtn: false,
    refreshBtn:false,
    column: [{
        label: "设备类别",
        prop: "equipmentTypeId",
        slot: true,
    },{
        label: "设备编号",
        prop: "coded",
    },{
        label: "设备名称",
        prop: "name",
    },{
        label: "设备型号",
        prop: "marking",
    },{
        label: "品牌",
        prop: "brand",
    },{
        label: "实验室",
        prop: "laboratoryId",
        slot: true,
    },{
        label: "预约时间",
        prop: "time",
        slot: true,
    }]
};

export const optionSelect = {
    index: true,
    size: 'mini',
    indexLabel:'序号',
    border: true,
    selection: true,
    addBtn: false,
    cellBtn: false,
    editBtn: false,
    delBtn: false,
    searchBtn: true,
    dicData: DIC,
    align: "center",
    menu: false,
    menuWidth: 80,
    menuAlign: "center",
    columnBtn: false,
    refreshBtn: false,
    column: [{
        label: "设备类别",
        prop: "equipmentTypeId",
        slot: true,
    },{
        label: "设备编码",
        prop: "coded",
    },{
        label: "设备名称",
        prop: "name",
    },{
        label: "设备型号",
        prop: "marking",
    },{
        label: "实验室",
        prop: "laboratoryId",
        slot: true,
    },{
        label: "品牌",
        prop: "brand",
    }]
};

export const tableOptionModeSelectRLDateFormRules = {
    beginDate: [
        {type: 'date', required: true, message: '请输入开始时间', trigger: 'change'},
    ],
    endDate: [
        {type: 'date', required: true, message: '请选择开始时间', trigger: 'change'},
    ],
    beginTime: [
        {required: true, message: '请输入结束时间', trigger: 'change'},
    ],
    endTime: [
        {required: true, message: '请选择结束时间', trigger: 'change'},
    ],
}

export function jsonToArray(nodes) {
    var r=[];
    if (Array.isArray(nodes)) {
      for (var i=0, l=nodes.length; i<l; i++) {
        r.push(nodes[i]); // 取每项数据放入一个新数组
        if (Array.isArray(nodes[i]["children"])&&nodes[i]["children"].length>0)
         // 若存在children则递归调用，把数据拼接到新数组中，并且删除该children
          r = r.concat(jsonToArray(nodes[i]["children"]));
            delete nodes[i]["children"]
      }
    } 
    return r;
}
